package com.siao.component
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	
	/**
	 * 基于影片剪辑的四态按钮
	 * @author SiaoLeon
	 */
	public class ButtonClip extends StateButton
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		override public function set content(value:DisplayObject):void
		{
			super.content = value;
			
			this.enabled = true;
		}
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 * @param clip 四帧的按钮影片剪辑，四帧分别为四种状态：常态、划过、按下、不可用
		 */
		public function ButtonClip(clip:MovieClip)
		{
			super();
			
			this.content = clip;
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		// -------------------------------------------------------------------------------------------------------- 函数
		
		override protected function onNormal():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop(1);
			}
		}
		
		override protected function onMouseOver():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop(2);
			}
		}
		
		override protected function onMouseDown():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop(3);
			}
		}
		
		override protected function onDisabled():void
		{
			if (this.content != null)
			{
				(this.content as MovieClip).gotoAndStop(4);
			}
		}
	
	}
}
